<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<!DOCTYPE html>
<html>
<head>
<title>编辑联系人</title>
</head>
<body>
  <div style="text-align: center">
    <form action="contact-handler" method="post">
      <input type="hidden" name="operate" value="modify-contact">
      <fieldset>
        <legend>修改联系人</legend>
        <label>编号<input type="text" name="contact-id" value="${requestScope.contact.contactId}" readonly="readonly"></label>
        <br>
        <label>姓名<input type="text" name="contact-name" value="${requestScope.contact.contactName}"></label><br>
        性别<select name="sex" title="选择性别">
          <option value="1"
            <c:if test="${requestScope.contact.sex==1}"><c:out value=" selected" /></c:if>>男</option>
          <option value="0"
            <c:if test="${requestScope.contact.sex==0}"><c:out value=" selected" /></c:if>>女</option>
        </select><br>
        <label>生日<input type="text" name="birthdate" placeholder="yyyy-MM-dd" value="${requestScope.contact.birthdate}"></label><br>
        <label>电话<input type="text" name="telephone" value="${requestScope.contact.telephone}"></label><br>
        <label>组<select name="group-id">
            <c:if test="${requestScope.groups.size()>0}">
              <c:forEach items="${groups}" var="group">
                <c:choose>
                  <c:when test="${requestScope.contact.groupId!=group.groupId}">
                    <option value="${group.groupId}">${group.groupName}</option>
                  </c:when>
                  <c:otherwise>
                    <option value="${group.groupId}" selected>${group.groupName}</option>
                  </c:otherwise>
                </c:choose>
              </c:forEach>
            </c:if>
          </select>
        </label>
        <input type="submit" value="更新">
      </fieldset>
    </form>
  </div>
</body>
</html>
